package com.zhuss.repair.db.dao.ext;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhuss.bean.bo.repair.repair.SearchRepairBo;
import com.zhuss.bean.bo.repair.repairKancha.RepairKanchaBo;
import com.zhuss.bean.vo.food.food.DetailFoodVo;
import com.zhuss.bean.vo.repair.repair.DetailRepairVo;
import com.zhuss.bean.vo.repair.repair.KanchaQTVo;
import com.zhuss.bean.vo.repair.repair.ListRepairVo;
import com.zhuss.bean.vo.repair.repair.RepairKanchaVo;
import com.zhuss.repair.db.dao.gen.RepairMapper;
import com.zhuss.repair.db.entity.Repair;
import com.zhuss.repair.db.entity.RepairAudit;
import com.zhuss.repair.db.entity.RepairKancha;
import com.zhuss.repair.db.entity.RepairKanchaQT;
import com.zhuss.repair.db.entity.WeiXiuGoods;

@Mapper
public interface RepairKanchaDao {


	
	List<ListRepairVo> list(SearchRepairBo bo);

	Integer countList(SearchRepairBo bo);

	@Insert("INSERT INTO t_repair_kancha (repair_id,deal_user_id,content,remark,kancha_time,files,create_time) VALUES (#{repair_id,jdbcType=INTEGER},#{deal_user_id,jdbcType=INTEGER},#{content,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{kancha_time,jdbcType=VARCHAR},#{files,jdbcType=VARCHAR},NOW())")
	void insertRepairKancha(RepairKancha repairKancha);

	@Delete("delete from t_repair_kancha where repair_id = #{repair_id}")
	void cleartRepairKancha(RepairKancha repairKancha);

	@Delete("delete from t_repair_kancha_qt where repair_id = #{repair_id} and rows = #{rows}")
	void cleartRepairKanchaQT(RepairKanchaQT repairKancha);

	void insertRepairKanchaQT(RepairKanchaQT repairKancha);


	
	@Select("select * from t_repair_kancha where repair_id = #{repair_id} limit 1")
	RepairKanchaVo getRepair_kanchaByid(Integer repair_id);

	@Select("SELECT * FROM t_repair_kancha_qt where repair_id = #{repair_id} order by rows asc")
	List<KanchaQTVo> getRepair_kancha_qt(Integer repair_id);

	@Update("UPDATE t_repair SET step = #{step}, audit = #{audit} WHERE id = #{id}")
	void completeKancha(Repair record);

	@Delete("delete from t_repair_goods where repair_id = #{repair_id} and rows = #{rows}")
	void clearWeiXiuFoods(WeiXiuGoods repairKancha);
	
	
	void addWeiXiuGoods(WeiXiuGoods weiXiuFoods);

	@Select("select g.*,(SELECT value FROM t_config where type = 'RepairGoods' and config_key = g.goods_key limit 1) as goods_name from t_repair_goods g where g.repair_id = #{repair_id} and g.repair_step = #{repair_step} order by g.rows asc")
	List<WeiXiuGoods> getWeiXiuFoods(WeiXiuGoods repairKancha);


	
	
	

	
	
    
}